package com.base.recycleView.activity;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.base.mvvm2.MVVMBaseActivity2;
import com.base.recycleView.ViewModel.BaseRecycleViewModle;
import com.base.recycleView.adapter.BaseReceycleAdapter;
import com.gml.gao.R;
import com.gml.gao.databinding.CommonRecyclviewBinding;


/**
 * Created by gml on 17/2/21.
 */

public abstract class BaseRecyclViewActivity<T, A extends BaseReceycleAdapter<T>, M extends BaseRecycleViewModle<T, A> > extends MVVMBaseActivity2<M> {


    private A mAdapter;
    private  CommonRecyclviewBinding binding;
    @Override
    public void initView() {
        binding = DataBindingUtil.setContentView(this, R.layout.common_recyclview);
        binding.recyclerView.setLayoutManager(new LinearLayoutManager(this));//这里用线性显示 类似于listview
//        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));//这里用线性宫格显示 类似于grid view
//        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(1, OrientationHelper.VERTICAL));//这里用线性宫格显示 类似于瀑布流

//        List<Employee> demoList = new ArrayList<>();
//        demoList.add(new Employee("Zhai", "Mark", false));
//        demoList.add(new Employee("Zhai2", "Mark2", false));
//        demoList.add(new Employee("Zhai3", "Mark3", true));
//        demoList.add(new Employee("Zhai4", "Mark4", false));
//        madapter.addAll(demoList);
        mAdapter = mPresenter.gettSimpleAdapter();
        binding.setLvAdapter( mAdapter);
        binding.add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPresenter.findall();
            }
        });
    }
}
